In computer programming, a thread is an instance of a sequence of code that operates as a unit on behalf of a single user, transaction, or message. Threads are sometimes described in terms of their weight, which describes how much contextual information must be saved for a given thread so that it can be referred by the system during the life of the thread.
A program that is split up into multiple threads is said to be multi-threaded. On a multi-processor system or in a system utilizing a processor that supports multi-threaded software, the multiple threads may be executed together in parallel. Each of the threads in the program may execute program code sequentially or may further be split up into child threads that may be executed in parallel. Threads have their own program counters and stacks. Similar to traditional processes, threads can be thought of as being in one of several states: running, blocked, ready, or terminated. A running thread has access to the processor and is active. A blocked thread is waiting for another thread to unblock it (e.g., on a semaphore). A ready thread is scheduled to run, but is waiting for the processor. A terminated thread is one that has exited.
Inactive threads are threads that are blocked or threads that are scheduled to run but are waiting for the processor. Current performance analyzer tools are unable to efficiently measure the wait time of inactive threads. These performance analyzer tools either do not have the capability to analyze threads that are not currently running or impose an intrusive protocol to measure the wait time of inactive threads which slows the program time to the point that real-time issues are less visible.
Thus, an effective and efficient method and apparatus for measuring thread wait time is desired.